package zzh.com.kangkenuo.utils;

import android.content.Context;
import android.util.Log;
import android.webkit.CookieManager;

import com.tencent.smtt.sdk.WebView;

/**
 * Created by Administrator on 2017-01-17.
 */
public class NetUtils {
    public static void setCookie(Context context, String url, WebView webview) {
        String uidValue = TotalFunction.ReadData(context, "ECS_ID") + ";";
        if (uidValue.length() > 11) {
            // 获得cookie管理者
            CookieManager cookieManager = CookieManager.getInstance();
            // 获取登陆时的cookie
            Log.e("", uidValue);
            cookieManager.setCookie(url, uidValue);
        }
        String ua = webview.getSettings().getUserAgentString();
        if (!(ua.indexOf("HzResfine") >= 0)) {
            webview.getSettings().setUserAgentString(ua + "; HzResfine");
        }
        webview.getSettings().setDefaultTextEncodingName("gbk");
        webview.loadUrl(url);
    }

    public static void cleanCookie(Context context) {
        TotalFunction.RemoveData(context, "ECS_ID");
    }

}

